﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace UpDownPhoneSample
{
    public partial class DemoCustom : PhoneApplicationPage
    {

        private string[] valuelist = new string[] { "Brazil", "France", "EUA", "Mexico", "Canada" };
        public DemoCustom()
        {
            InitializeComponent();
        }

        private void UpDn_UpDownValueChanged(object sender, UpDownPhone.UpDownCustomValueChangedEvent e)
        {
            if (e.NewValue.Equals(1))
            {
                e.CustomValue = "On";
            }
            else
            {
                e.CustomValue = "Off";
            }
        }

        private void UpDn1_UpDownValueChanged(object sender, UpDownPhone.UpDownCustomValueChangedEvent e)
        {
            if (e.OldValue.Equals(0))
            {
                e.CustomText = " level";
                e.NewValue = 10;
                e.CustomValue = "10";
                return;
            }
            if (e.NewValue < 10)
            {
                e.CustomValue = "Off";
                e.NewValue = 0;
                e.CustomText = string.Empty;
                return;
            }

            e.CustomValue = e.NewValue.ToString(CultureInfo.InvariantCulture);
            e.CustomText = " level";
        }

        private void UpDn2_UpDownValueChanged(object sender, UpDownPhone.UpDownCustomValueChangedEvent e)
        {
            e.CustomValue = valuelist[(int)e.NewValue];
        }

    }
}